import ajax from '@/utils/request'

// 获取用户基本资料
const getUserMsgAPI = () => {
  return ajax({
    method: 'GET',
    url: '/v1_0/user'
  })
}

// 用户信息编辑
const userEditAPI = () => {
  return ajax({
    method: 'GET',
    url: '/v1_0/user/profile'
  })
}

// 上传头像
const updatephotoAPI = ({ formDate }) => {
  return ajax({
    method: 'PATCH',
    url: '/v1_0/user/photo',
    data: formDate // formData是一个表单对象,格式是{photo: file}
  })
}
// 更新用户信息
const updateuserInfoAPI = ({ birthday, name }) => {
  return ajax({
    method: 'PATCH',
    url: '/v1_0/user/profile',
    data: {
      birthday,
      name
    }
  })
}
// token续签-------refreshToken
const updateTokenAPI = () => {
  return ajax({
    method: 'PUT',
    url: '/v1_0/authorizations'
  })
}

export {
  getUserMsgAPI,
  userEditAPI,
  updatephotoAPI,
  updateuserInfoAPI,
  updateTokenAPI
}
